var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function s() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (s.prototype = t.prototype, 
    new s());
}), a = this && this.__decorate || function(e, t, o, s) {
    var i, n = arguments.length, a = n < 3 ? t : null === s ? s = Object.getOwnPropertyDescriptor(t, o) : s;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, o, s); else for (var r = e.length - 1; 0 <= r; r--) (i = e[r]) && (a = (n < 3 ? i(a) : 3 < n ? i(t, o, a) : i(t, o)) || a);
    return 3 < n && a && Object.defineProperty(t, o, a), a;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameManager"), s = e("PlayerModel"), c = e("Global"), l = e("Player"), d = e("GameBlockEggs"), u = e("LoadManager"), p = cc._decorator.ccclass, h = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.skeleton = null, e.skeletonPath = null, e.sprite = null, e.spritePath = null, 
        e.motionStreak = null, e.model = null, e.dir = null, e.targetDir = null, e.pos = null, 
        e.speed = null, e.time = 0, e.duration = null, e.attacker = null, e.target = null, 
        e.radius = 240, e.isFollow = !1, e.isDestory = !1, e.isUse = !0, e;
    }
    return i(e, t), e.prototype.reuse = function() {
        this.isUse = !0;
    }, e.prototype.unuse = function() {
        this.isUse = !1;
    }, e.prototype.start = function() {}, e.prototype.init = function(e, t, o, i) {
        var n = this;
        switch (this.attacker = e, this.model = t, this.pos = i, null != o && (this.dir = o.rotate(cc.misc.degreesToRadians((Math.random() - .5) * this.model.ROT / 2)), 
        this.speed = this.dir.mul(this.model.MOV), this.updateDir(this.dir)), this.node.setPosition(i), 
        this.node.zIndex = this.model.fire, this.model.type) {
          case s.ArmType.正常:
          case s.ArmType.手枪:
            this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: .8
            }), 0 < this.speed.mag() ? this.duration = 1.5 * this.model.RAN / this.speed.mag() : this.duration = 1;
            break;

          case s.ArmType.加特林:
            this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: .5
            }), 0 < this.speed.mag() ? this.duration = 1.5 * this.model.RAN / this.speed.mag() : this.duration = 1;
            break;

          case s.ArmType.暴力枪:
            this.doScatter(o);
            break;

          case s.ArmType.狙击枪:
            this.appendSkeleton({
                url: "skeleton/game/bullet狙击枪2/skeleton",
                pos: cc.v2(50, 0),
                callback: function() {
                    n.isDestory ? n.clear() : n.skeleton.setAnimation(0, "penzi", !0);
                }
            }), this.duration = 2;
            break;

          case s.ArmType.闪电枪:
            this.doElectric(o);
            break;

          case s.ArmType.科技枪:
            this.dir && (this.speed = this.dir.mul(Math.round(400 * Math.random()) + 800)), 
            this.model.type = s.ArmType.追踪, this.appendMotionStreak({
                url: "motionStreak/32",
                fadeTime: .2,
                minSeg: 1,
                stroke: 30,
                color: cc.Color.WHITE
            }), this.doFollow(o);
            break;

          case s.ArmType.反弹枪:
            this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: .8,
                callback: function() {
                    n.appendMotionStreak({
                        url: "motionStreak/30",
                        fadeTime: .6,
                        minSeg: 1,
                        stroke: 5,
                        color: n.getColor(n.model.bullet)
                    });
                }
            }), this.duration = 2;
            break;

          case s.ArmType.导弹枪:
            this.appendSkeleton({
                url: "skeleton/game/bullet导弹枪/skeleton",
                pos: cc.v2(50, 0),
                callback: function() {
                    n.isDestory ? n.clear() : (e instanceof l.default ? n.skeleton.node.scale = .8 : n.skeleton.node.scale = .6, 
                    n.skeleton.setAnimation(0, "huojianpao3", !0));
                }
            }), this.duration = 2;
            break;

          case s.ArmType.激光枪:
            this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: 1,
                callback: function() {
                    n.sprite && cc.tween(n.sprite.node).repeat(2, cc.tween().to(.05, {
                        opacity: 0
                    }).to(.05, {
                        opacity: 255
                    })).start(), n.doLaser(30);
                }
            }), this.appendSkeleton({
                url: "skeleton/game/fire激光枪2/skeleton",
                pos: cc.v2(-25, 0),
                callback: function() {
                    n.isDestory ? n.clear() : (n.skeleton.timeScale = .5, n.skeleton.node.scale = .5, 
                    n.skeleton.node.zIndex = 1, 30 == n.model.bullet ? n.skeleton.node.color = cc.Color.RED : 31 == n.model.bullet ? n.skeleton.node.color = cc.Color.CYAN : 32 == n.model.bullet && (n.skeleton.node.color = cc.Color.GREEN), 
                    n.skeleton.setAnimation(0, "qiangkou", !1));
                }
            }), this.duration = .2;
            break;

          case s.ArmType.冰冻枪:
            this.model.gunIdx < 0 && Math.random() < .2 || Math.random() < .13 ? (this.radius = 160, 
            this.appendSkeleton({
                url: "skeleton/game/fire冰冻枪/skeleton",
                pos: cc.v2(-15, 0),
                callback: function() {
                    n.isDestory ? n.clear() : (n.skeleton.node.zIndex = 1, n.skeleton.setAnimation(0, "animation1", !0));
                }
            })) : (this.model.type = s.ArmType.正常, this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: .8
            })), this.duration = 1;
            break;

          case s.ArmType.火焰枪:
            break;

          case s.ArmType.旋风枪:
            this.appendSkeleton({
                url: "skeleton/game/bullet旋风/skeleton",
                pos: cc.Vec2.ZERO,
                callback: function() {
                    n.skeleton.node.scale = .8, n.skeleton.setAnimation(0, "animation", !0);
                }
            }), 0 < this.speed.mag() ? this.duration = 1.5 * this.model.RAN / this.speed.mag() : this.duration = 1;
            break;

          case s.ArmType.闪雷枪:
            this.appendSkeleton({
                url: "skeleton/game/bullet闪雷枪/skeleton",
                pos: cc.v2(-15, 0),
                callback: function() {
                    n.isDestory ? n.clear() : n.skeleton.setAnimation(0, "animation", !0);
                }
            }), this.duration = 1;
            break;

          case s.ArmType.炎弹枪:
            this.appendSkeleton({
                url: "skeleton/game/bullet炎弹枪/skeleton",
                pos: cc.v2(-15, 0),
                callback: function() {
                    n.isDestory ? n.clear() : n.skeleton.setAnimation(0, "animation", !0);
                }
            }), this.duration = 1;
            break;

          case s.ArmType.火球:
            this.appendSkeleton({
                url: "skeleton/game/fire火球/zidan",
                pos: cc.v2(50, 0),
                callback: function() {
                    n.isDestory ? n.clear() : (n.skeleton.node.angle = n.node.angle + 180, n.skeleton.setAnimation(0, "zidan", !0));
                }
            }), this.duration = 1;
            break;

          case s.ArmType.落雷:
            this.appendSkeleton({
                url: "skeleton/game/fire落雷/skeleton",
                pos: cc.v2(0, 0),
                callback: function() {
                    n.isDestory ? n.clear() : (n.skeleton.setEventListener(function(e, t) {
                        n.skeleton.setEventListener(null), "attack" == t.data.name && n.doRange(n.node.getPosition(), 240);
                    }), n.skeleton.setCompleteListener(function() {
                        n.skeleton.setCompleteListener(null), n.doDestory();
                    }), n.skeleton.setAnimation(0, "animation", !1));
                }
            }), this.duration = 2;
            break;

          case s.ArmType.回旋:
            this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: .9,
                callback: function() {
                    cc.tween(n.sprite.node).repeatForever(cc.tween().by(.1, {
                        angle: 360
                    })).start(), n.appendMotionStreak({
                        url: "motionStreak/30",
                        fadeTime: .6,
                        minSeg: 1,
                        stroke: 5,
                        color: n.getColor(n.model.bullet)
                    });
                }
            }), this.duration = 3;
            break;

          case s.ArmType.毒液:
            this.doVenom(o);
            break;

          case s.ArmType.冲击:
            this.appendSkeleton({
                url: "skeleton/game/hurt13/shoujitexiao",
                pos: cc.v2(0, 0),
                callback: function() {
                    n.skeleton.node.scale = 1.5, n.skeleton.setAnimation(0, "attack", !1), n.doRange(n.node.getPosition(), n.model.RAN), 
                    n.skeleton.setCompleteListener(function() {
                        n.skeleton.setCompleteListener(null), n.doDestory();
                    });
                }
            });
            break;

          case s.ArmType.追踪:
            this.appendMotionStreak({
                url: "motionStreak/32",
                fadeTime: .2,
                minSeg: 1,
                stroke: 30,
                color: cc.Color.WHITE
            }), this.doFollow(o);
            break;

          case s.ArmType.旋风:
            this.node.setContentSize(100, 100), this.appendSkeleton({
                url: "skeleton/game/bullet旋风/skeleton",
                pos: cc.Vec2.ZERO,
                callback: function() {
                    n.skeleton.node.scale = 1.5, n.skeleton.node.angle = 0, n.skeleton.setAnimation(0, "animation", !0);
                }
            }), this.duration = 2;
            break;

          case s.ArmType.炎弹:
            break;

          case s.ArmType.闪雷:
            this.radius = 160, this.appendSkeleton({
                url: "skeleton/game/bullet闪雷/skeleton",
                pos: cc.v2(-15, 0),
                callback: function() {
                    n.isDestory ? n.clear() : n.skeleton.setAnimation(0, "animation", !0);
                }
            }), this.duration = 1;
            break;

          default:
            this.appendBullet({
                bullet: this.model.bullet,
                pos: cc.Vec2.ZERO,
                scale: .8,
                callback: function() {
                    n.appendMotionStreak({
                        url: "motionStreak/30",
                        fadeTime: .4,
                        minSeg: 1,
                        stroke: 8,
                        color: n.getColor(n.model.bullet)
                    });
                }
            }), 0 < this.speed.mag() ? this.duration = 1.5 * this.model.RAN / this.speed.mag() : this.duration = 1;
        }
    }, e.prototype.appendBullet = function(e) {
        var t = this;
        if (this.spritePath != "texture/bullet/" + e.bullet) {
            this.spritePath = "texture/bullet/" + e.bullet, null == this.sprite ? this.sprite = r.default.getInstance().gameView.getSprite().getComponent(cc.Sprite) : this.sprite.spriteFrame = null;
            try {
                this.sprite.node.angle = this.node.angle + 90, e.scale ? this.sprite.node.setScale(e.scale) : this.sprite.node.setScale(1), 
                50 == e.bullet && cc.tween(this.sprite.node).repeatForever(cc.tween().by(.1, {
                    angle: 360
                })).start(), this.sprite.node.setPosition(this.node.getPosition()), this.sprite.node.setParent(r.default.getInstance().gameView.bulletSpriteLayout), 
                this.sprite.node.active = !0;
                var o = "texture/bullet/" + e.bullet;
                u.default.getInstance().loadSpriteFrame({
                    url: o,
                    sprite: this.sprite,
                    success: function() {
                        try {
                            t.model && t.spritePath == o && e.callback && e.callback();
                        } catch (e) {
                            cc.error(e);
                        }
                    }
                });
            } catch (e) {
                cc.error(e);
            }
        } else this.sprite.node.angle = this.node.angle + 90, e.scale ? this.sprite.node.setScale(e.scale) : this.sprite.node.setScale(1), 
        50 == e.bullet && cc.tween(this.sprite.node).repeatForever(cc.tween().by(.1, {
            angle: 360
        })).start(), this.sprite.node.setPosition(this.node.getPosition()), this.sprite.node.setParent(r.default.getInstance().gameView.bulletSpriteLayout), 
        this.sprite.node.active = !0, e.callback && e.callback();
    }, e.prototype.appendSkeleton = function(t) {
        var o = this;
        if (this.skeletonPath != t.url) {
            this.skeletonPath = t.url, null == this.skeleton ? this.skeleton = r.default.getInstance().gameView.getSkeleton().getComponent(sp.Skeleton) : this.skeleton.skeletonData = null;
            try {
                t.scale ? this.skeleton.node.setScale(t.scale) : this.skeleton.node.setScale(1), 
				this.skeleton.premultipliedAlpha = false,
                this.skeleton.node.angle = this.node.angle, this.skeleton.node.setPosition(this.node.getPosition()), 
                this.skeleton.node.setParent(r.default.getInstance().gameView.bulletSkeletonLayout), 
                this.skeleton.node.zIndex = this.model.type, this.skeleton.node.active = !0, u.default.getInstance().loadRes({
                    url: t.url,
                    type: sp.SkeletonData
                }).then(function(e) {
                    try {
                        o.model && o.skeletonPath == t.url && (o.skeleton.skeletonData = e,o.skeleton.premultipliedAlpha = false, t.callback && t.callback());
                    } catch (e) {
                        cc.error(e);
                    }
                });
            } catch (e) {
                cc.error(e);
            }
        } else t.scale ? this.skeleton.node.setScale(t.scale) : this.skeleton.node.setScale(1), 
        this.skeleton.node.angle = this.node.angle, this.skeleton.node.setPosition(this.node.getPosition()), 
        this.skeleton.node.setParent(r.default.getInstance().gameView.bulletSkeletonLayout), 
        this.skeleton.node.zIndex = this.model.type, this.skeleton.node.active = !0, t.callback && t.callback();
    }, e.prototype.appendMotionStreak = function(e) {
        var t = this;
        null == e.fadeTime && (e.fadeTime = .2), null == e.minSeg && (e.minSeg = 1), null == e.stroke && (e.stroke = 8), 
        null == e.color && (e.color = cc.Color.YELLOW), null == this.motionStreak && (this.motionStreak = new cc.Node().addComponent(cc.MotionStreak), 
        this.motionStreak.node.setScale(.5), this.motionStreak.node.angle = -90, this.motionStreak.node.zIndex = 100), 
        this.motionStreak.fadeTime = e.fadeTime, this.motionStreak.minSeg = e.minSeg, this.motionStreak.stroke = e.stroke, 
        this.motionStreak.color = e.color, u.default.getInstance().loadRes({
            url: e.url,
            type: cc.SpriteFrame
        }).then(function(e) {
            t.motionStreak && (t.motionStreak.texture = e.getTexture(), t.motionStreak.node.setParent(t.node));
        }).catch(function(e) {
            console.error(e);
        });
    }, e.prototype.appendParticle = function(i) {
        var n = this;
        return new Promise(function(o, s) {
            u.default.getInstance().loadRes({
                url: "prefab/particle",
                type: cc.Prefab
            }).then(function(e) {
                var t = cc.instantiate(e).getComponent(cc.ParticleSystem);
                t.node.setParent(n.node.getParent()), Promise.all([ new Promise(function(o) {
                    cc.resources.load(i.particleUrl, cc.ParticleAsset, function(e, t) {
                        o(t);
                    });
                }), u.default.getInstance().loadRes({
                    url: i.spriteUrl,
                    type: cc.SpriteFrame
                }) ]).then(function(e) {
                    try {
                        t.file = e[0], t.spriteFrame = e[1], t.autoRemoveOnFinish = !0, o(t);
                    } catch (e) {
                        s();
                    }
                }).catch(function() {
                    t.node.destroy(), s();
                });
            }).catch(function() {
                s();
            });
        });
    }, e.prototype.check = function(e) {
        var o = this, t = [], s = r.default.getInstance().gameView.astar.retrievePos(this.node.getPosition(), this.node.getPosition().add(this.speed.mul(e))).filter(function(e) {
            return e.isCanBlock(o.model.type) || e.isCanAttacked(o.model.type);
        }), e = this.checkTargets(e);
        if (0 < (t = t.concat(s.map(function(e) {
            return {
                type: "block",
                item: e
            };
        })).concat(e.map(function(e) {
            return {
                type: "target",
                item: e
            };
        })).sort(function(e, t) {
            return e.item.node.getPosition().sub(o.node.getPosition()).mag() - t.item.node.getPosition().sub(o.node.getPosition()).mag();
        })).length) switch (t[0].type) {
          case "block":
            return this.hintBlock(t[0].item);

          case "target":
            return this.hintTarget(t[0].item);
        }
        return !1;
    }, e.prototype.checkTargets = function(o, s) {
        var i = this;
        void 0 === s && (s = this.node.getBoundingBox());
        var n = cc.v2((s.xMin + s.xMax) / 2, (s.yMin + s.yMax) / 2);
        return r.default.getInstance().gameView.targets.filter(function(e) {
            if (e.checkTarget(e) && e.canHurt() && e.model.group != i.model.group) {
                var t = e.node.getBoundingBox();
                return t.x += 10, t.y += e.skeleton.node.y + 50, t.width -= 10, t.height -= 10, 
                cc.Intersection.lineRect(n, n.add(i.speed.mul(o)), t) || n.sub(cc.v2(t.x, t.y)).mag() <= t.width / 2 + s.width / 2;
            }
            return !1;
        });
    }, e.prototype.clear = function() {
        this.target = null, cc.Tween.stopAllByTarget(this.node), r.default.getInstance().gameView && this.skeleton && r.default.getInstance().gameView.removeSkeleton(this.skeleton.node), 
        this.skeleton = null, this.skeletonPath = null, r.default.getInstance().gameView && this.sprite && r.default.getInstance().gameView.removeSprite(this.sprite.node), 
        this.sprite = null, this.spritePath = null, this.motionStreak && (this.motionStreak.node && this.motionStreak.node.destroy(), 
        this.motionStreak = null), this.node.scale = 1, this.node.destroyAllChildren(), 
        this.node.setContentSize(20, 20), this.model = null, this.dir = null, this.pos = null, 
        this.speed = null, this.attacker = null, this.target = null, this.radius = 240, 
        this.time = 0, this.duration = null, this.isFollow = !1, this.isDestory = !1, r.default.getInstance().gameView.putArm(this.node);
    }, e.prototype.doDestory = function() {
        var t, e = this;
        this.isDestory || (this.isDestory = !0, cc.Tween.stopAllByTarget(this.node), this.model.type === s.ArmType.激光枪 || this.model.type === s.ArmType.冰冻枪 || this.model.type == s.ArmType.火焰枪 || this.model.type == s.ArmType.冲锋枪 || this.model.type === s.ArmType.落雷 || this.model.type == s.ArmType.回旋 || this.model.type === s.ArmType.冲击 || this.model.type == s.ArmType.闪雷 ? this.clear() : this.model.type == s.ArmType.追踪 ? this.appendSkeleton({
            url: "skeleton/game/hurt冰冻枪/skeleton",
            pos: cc.v2(50, 0),
            callback: function() {
                e.skeleton.setAnimation(0, "penzi", !1), e.skeleton.setCompleteListener(function() {
                    e.skeleton.setCompleteListener(null), e.clear();
                });
            }
        }) : this.model.type === s.ArmType.火球 ? this.appendSkeleton({
            url: "skeleton/game/hurt13/shoujitexiao",
            pos: cc.v2(50, 0),
            callback: function() {
                e.skeleton.node.angle = 0, e.skeleton.setAnimation(0, "attack", !1), e.skeleton.setCompleteListener(function() {
                    e.skeleton.setCompleteListener(null), e.clear();
                });
            }
        }) : this.model.type === s.ArmType.导弹枪 ? this.appendSkeleton({
            url: "skeleton/game/hurt导弹枪/skeleton",
            pos: cc.v2(50, 0),
            callback: function() {
                e.skeleton.node.angle = -e.node.angle, e.skeleton.node.scale = e.radius / 100, e.skeleton.setAnimation(0, "huojianpao2", !1), 
                e.skeleton.setCompleteListener(function() {
                    e.skeleton.setCompleteListener(null), e.clear();
                });
            }
        }) : this.model.type === s.ArmType.狙击枪 ? this.appendSkeleton({
            url: "skeleton/game/hurt狙击枪2/skeleton",
            pos: cc.v2(50, 0),
            callback: function() {
                e.skeleton.node.scale = 1.5, e.skeleton.setAnimation(0, "animation", !1), e.skeleton.setCompleteListener(function() {
                    e.skeleton.setCompleteListener(null), e.clear();
                });
            }
        }) : this.model.type === s.ArmType.加特林 ? this.appendSkeleton({
            url: "skeleton/game/hurt狙击枪2/skeleton",
            pos: cc.v2(50, 0),
            callback: function() {
                e.skeleton.node.scale = 1, e.skeleton.setAnimation(0, "animation", !1), e.skeleton.setCompleteListener(function() {
                    e.skeleton.setCompleteListener(null), e.clear();
                });
            }
        }) : (t = this.node.getPosition(), this.appendParticle({
            particleUrl: "particle/hurt/shoujitexiao",
            spriteUrl: "particle/hurt/shoujitexiao"
        }).then(function(e) {
            try {
                e && (e.node.setPosition(t), e.resetSystem());
            } catch (e) {}
        }), this.clear()), r.default.getInstance().gameView && this.sprite && r.default.getInstance().gameView.removeSprite(this.sprite.node), 
        this.sprite = null, this.spritePath = null, this.motionStreak && (this.motionStreak.node && this.motionStreak.node.destroy(), 
        this.motionStreak = null));
    }, e.prototype.doFollow = function(e) {
        var t = this;
        this.findTarget();
        var o = this.target && this.target.node ? this.target.node.getPosition() : cc.v2(this.pos.add(e.mul(this.model.RAN * (.3 * Math.random() + .7)))), e = cc.tween(this.node);
        (e = c.G.bezierTo(1, this.pos.add(cc.v2(Math.round(600 * (Math.random() - .5)), Math.round(600 * (Math.random() - .5)))), o.add(cc.v2(Math.round(600 * (Math.random() - .5)), Math.round(600 * (Math.random() - .5)))), o.add(cc.v2(Math.round(480 * Math.random()) - 80, Math.round(480 * Math.random() - 80))), {
            easing: "quadIn"
        }, e)).call(function() {
            t.isFollow = !0;
        }).delay(3).call(function() {
            t.doDestory();
        }).start();
    }, e.prototype.doScatter = function(o) {
        var s = this;
        r.default.getInstance().gameView.astar.retrieve(this.getRectByVec(this.pos, o.mul(this.model.RAN), 30)).forEach(function(e) {
            var t;
            !e.isCanAttacked(s.model.type) || (t = e.node.getPosition().sub(s.pos)).mag() < s.model.RAN && cc.misc.radiansToDegrees(t.angle(o)) < 30 && e.doHurt(s.model, s.dir);
        }), r.default.getInstance().gameView.targets.forEach(function(e) {
            var t;
            e && e.checkTarget(e) && e.canHurt() && e.model.group != s.model.group && ((t = e.node.getPosition().sub(s.pos)).mag() < s.model.RAN && cc.misc.radiansToDegrees(t.angle(o)) < 30 && e.doHurt(s.model, s.dir));
        }), this.appendSkeleton({
            url: "skeleton/game/fire暴力枪/skeleton",
            pos: cc.Vec2.ZERO,
            callback: function() {
                s.skeleton.node.scale = 2, s.skeleton.setAnimation(0, "penzi", !1), s.skeleton.setCompleteListener(function() {
                    s.skeleton.setCompleteListener(null), s.isDestory || s.clear();
                });
            }
        });
    }, e.prototype.doElectric = function(t) {
        var o = this;
        r.default.getInstance().gameView.astar.retrieve(this.getRectByVec(this.pos, t.mul(this.model.RAN), 0)).forEach(function(e) {
            e.isCanAttacked(o.model.type) && e.node.getPosition().sub(o.pos).mag() < o.model.RAN && cc.Intersection.pointLineDistance(e.node.getPosition(), o.pos, o.pos.add(t.mul(o.model.RAN)), !0) < 50 && e.doHurt(o.model, o.dir);
        }), r.default.getInstance().gameView.targets.forEach(function(e) {
            e && e.checkTarget(e) && e.canHurt() && e.model.group != o.model.group && e.node.getPosition().sub(o.pos).mag() < o.model.RAN && cc.Intersection.pointLineDistance(e.node.getPosition(), o.pos, o.pos.add(t.mul(o.model.RAN)), !0) < 50 && e.doHurt(o.model, o.dir);
        }), 44 < this.model.gunIdx ? this.appendSkeleton({
            url: "skeleton/game/fire闪电枪2/skeleton",
            pos: cc.v2(-40, 0),
            callback: function() {
                o.skeleton.node.scale = 1, o.skeleton.timeScale = 1, o.skeleton.setAnimation(0, "animation", !1), 
                o.skeleton.setCompleteListener(function() {
                    o.skeleton.setCompleteListener(null), o.isDestory || o.clear();
                });
            }
        }) : this.appendSkeleton({
            url: "skeleton/game/fire闪电枪/skeleton",
            pos: cc.v2(-40, 0),
            callback: function() {
                o.skeleton.node.scale = 1, o.skeleton.timeScale = 1, o.skeleton.setAnimation(0, "animation", !1), 
                o.skeleton.setCompleteListener(function() {
                    o.skeleton.setCompleteListener(null), o.isDestory || o.clear();
                });
            }
        });
    }, e.prototype.doVenom = function(t) {
        var o = this;
        r.default.getInstance().gameView.astar.retrieve(this.getRectByVec(this.pos, t.mul(this.model.RAN), 0)).forEach(function(e) {
            e.isCanAttacked(o.model.type) && e.node.getPosition().sub(o.pos).mag() < o.model.RAN && cc.Intersection.pointLineDistance(e.node.getPosition(), o.pos, o.pos.add(t.mul(o.model.RAN)), !0) < 50 && e.doHurt(o.model, o.dir);
        }), r.default.getInstance().gameView.targets.forEach(function(e) {
            e && e.checkTarget(e) && e.canHurt() && e.model.group != o.model.group && e.node.getPosition().sub(o.pos).mag() < o.model.RAN && cc.Intersection.pointLineDistance(e.node.getPosition(), o.pos, o.pos.add(t.mul(o.model.RAN)), !0) < 50 && e.doHurt(o.model, o.dir);
        }), this.appendSkeleton({
            url: "skeleton/game/fire1007/skeleton",
            pos: cc.v2(0, 0),
            callback: function() {
				o.skeleton.premultipliedAlpha = false,
                o.skeleton.node.scale = 1, o.skeleton.timeScale = 1, o.skeleton.setAnimation(0, "animation", !1), 
                o.skeleton.setCompleteListener(function() {
                    o.skeleton.setCompleteListener(null), o.isDestory || o.clear();
                });
            }
        });
    }, e.prototype.doBounce = function(e) {
        for (var o = this, t = this.speed.mul(e), s = r.default.getInstance().gameView.astar.retrievePos(this.node.getPosition(), this.node.getPosition().add(this.speed.mul(e))).filter(function(e) {
            return e.isCanBlock(o.model.type) || e.isCanAttacked(o.model.type);
        }).sort(function(e, t) {
            return e.node.getPosition().sub(o.node.getPosition()).mag() - t.node.getPosition().sub(o.node.getPosition()).mag();
        }), i = 0; i < s.length; i++) if (s[i].isCanBlock(this.model.type)) {
            if (-1 < (a = this.lineRect(this.node.getPosition(), t, s[i].node.getBoundingBox()))) return s[i].isCanAttacked(this.model.type) && s[i].doHurt(this.model, this.dir), 
            0 == a || 2 == a ? this.speed.x = -this.speed.x : 1 != a && 3 != a || (this.speed.y = -this.speed.y), 
            this.updateDir(this.speed.normalize()), void this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
            if (-1 == a) return s[i].isCanAttacked(this.model.type) && s[i].doHurt(this.model, this.dir), 
            void this.doDestory();
        } else s[i].isCanAttacked(this.model.type) && s[i].doHurt(this.model, this.dir);
        for (i = 0; i < r.default.getInstance().gameView.targets.length; i++) {
            var n = r.default.getInstance().gameView.targets[i];
            if (n && n.checkTarget(n) && n.canHurt() && n.model.group != this.model.group) {
                var a, l = n.node.getBoundingBox(), l = cc.rect(l.x + 10, l.y + n.skeleton.node.y + 50, l.width - 10, l.height - 10);
                if (-1 < (a = this.lineRect(this.node.getPosition(), t, l))) return n.doHurt(this.model, this.dir), 
                0 == a || 2 == a ? this.speed.x = -this.speed.x : 1 != a && 3 != a || (this.speed.y = -this.speed.y), 
                this.updateDir(this.speed.normalize()), void this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                if (-1 == a) return n.doHurt(this.model, this.dir), void this.doDestory();
            }
        }
        this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
    }, e.prototype.doMissile = function(e, t) {
        var o = this;
        void 0 === t && (t = this.radius);
        var s = [], i = r.default.getInstance().gameView.astar.retrievePos(this.node.getPosition(), this.node.getPosition().add(this.speed.mul(e))).filter(function(e) {
            return e.isCanBlock(o.model.type);
        }), e = this.checkTargets(e, cc.rect(this.node.x - 20, this.node.y - 20, 40, 40));
        if (0 < (s = s.concat(i.map(function(e) {
            return {
                type: "block",
                item: e
            };
        })).concat(e.map(function(e) {
            return {
                type: "target",
                item: e
            };
        })).sort(function(e, t) {
            return e.item.node.getPosition().sub(o.node.getPosition()).mag() - t.item.node.getPosition().sub(o.node.getPosition()).mag();
        })).length) {
            try {
                s[0].item instanceof d.default && s[0].item.doHurt(this.model, this.dir), this.doRange(s[0].item.node.getPosition(), t);
            } catch (e) {
                cc.error(e);
            }
            return !0;
        }
        return !1;
    }, e.prototype.doLaser = function(t) {
        var o = this;
        void 0 === t && (t = 20);
        try {
            for (var e = r.default.getInstance().gameView.astar.retrieve(this.getRectByVec(this.pos, this.speed.mul(.9), 0)).filter(function(e) {
                return (e.isCanBlock(o.model.type) || e.isCanAttacked(o.model.type)) && cc.Intersection.pointLineDistance(e.node.getPosition(), o.pos, o.pos.add(o.speed.mul(.9)), !0) < 2.5 * t;
            }).sort(function(e, t) {
                return e.node.getPosition().sub(o.node.getPosition()).mag() - t.node.getPosition().sub(o.node.getPosition()).mag();
            }), s = this.speed.mul(.9).mag(), i = 0; i < e.length; i++) {
                var n = e[i];
                if (n.isCanBlock(this.model.type)) {
                    if (!n.isCanAttacked(this.model.type)) {
                        s = n.node.getPosition().sub(this.node.getPosition()).mag();
                        break;
                    }
                    if (!n.doHurt(this.model, this.dir)) {
                        s = n.node.getPosition().sub(this.node.getPosition()).mag();
                        break;
                    }
                } else n.isCanAttacked(this.model.type) && n.doHurt(this.model, this.dir);
            }
            r.default.getInstance().gameView.targets.forEach(function(e) {
                e && e.checkTarget(e) && e.canHurt() && e.model.group != o.model.group && e.node.getPosition().sub(o.node.getPosition()).mag() < s && cc.Intersection.pointLineDistance(e.node.getPosition(), o.pos, o.pos.add(o.speed.mul(.9)), !0) < 2.5 * t && e.doHurt(o.model, o.dir);
            });
            var a = 0 == e.length ? this.speed.mul(.9).mag() : s - 40;
            this.sprite ? (this.sprite.node.active = !0, this.sprite.node.anchorY = 1, this.sprite.node.height = a, 
            this.sprite.node.width = t) : cc.log("激光sprite不存在");
            var l = this.node.getPosition().add(this.speed.normalize().mul(a));
            this.appendParticle({
                particleUrl: "particle/hurt/laser",
                spriteUrl: "particle/hurt/" + this.model.bullet
            }).then(function(e) {
                try {
                    e && (e.node.setPosition(l), e.resetSystem());
                } catch (e) {}
            });
        } catch (e) {
            cc.error(e);
        }
    }, e.prototype.doRange = function(t, o, e) {
        var s = this;
        null != e && !isNaN(e) || (e = o), r.default.getInstance().gameView.astar.retrieve(cc.rect(t.x - o, t.y - o, 2 * o, 2 * e)).forEach(function(e) {
            e.isCanAttacked(s.model.type) && e.node.getPosition().sub(t).mag() <= o && e.doHurt(s.model, s.dir);
        }), r.default.getInstance().gameView.targets.forEach(function(e) {
            e && e.checkTarget(e) && e.canHurt() && e.model.group != s.model.group && e.node.getPosition().sub(t).mag() < o && (s.speed = e.node.getPosition().sub(s.node.getPosition()).normalize().mul(s.speed.mag()), 
            e.doHurt(s.model, s.dir));
        });
    }, e.prototype.lineRect = function(e, t, o) {
        var s = e.add(t), i = t.mag(), n = cc.v2((o.x + o.xMax) / 2, (o.y + o.yMax) / 2);
        if (Math.abs(n.x - e.x) <= o.width / 2 + i && Math.abs(n.y - e.y) <= o.height / 2 + i && (Math.abs(n.x - e.x) > o.width / 2 || Math.abs(n.y - e.y) > o.height / 2)) {
            var a = cc.v2(o.x, o.y), r = cc.v2(o.x, o.yMax), l = cc.v2(o.xMax, o.yMax), t = cc.v2(o.xMax, o.y), i = [];
            return cc.Intersection.lineLine(e, s, a, r) && i.push({
                i: 0,
                d: a.sub(e).mag() + r.sub(e).mag()
            }), cc.Intersection.lineLine(e, s, r, l) && i.push({
                i: 1,
                d: r.sub(e).mag() + l.sub(e).mag()
            }), cc.Intersection.lineLine(e, s, l, t) && i.push({
                i: 2,
                d: l.sub(e).mag() + t.sub(e).mag()
            }), cc.Intersection.lineLine(e, s, t, a) && i.push({
                i: 3,
                d: t.sub(e).mag() + a.sub(e).mag()
            }), 0 < i.length ? (i.sort(function(e, t) {
                return e.d - t.d;
            }), i[0].i) : -2;
        }
        return Math.abs(n.x - e.x) < o.width / 2 && Math.abs(n.y - e.y) < o.height / 2 ? -1 : -2;
    }, e.prototype.getColor = function(e) {
        switch (e) {
          case 0:
            return cc.color(255, 255, 0);

          case 10:
            return cc.color(200, 255, 100);

          case 1:
            return cc.color(255, 0, 255);

          case 11:
            return cc.color(255, 100, 200);

          case 2:
            return cc.color(255, 50, 0);

          case 12:
            return cc.color(255, 200, 100);

          case 3:
            return cc.color(0, 255, 255);

          case 13:
            return cc.color(100, 200, 255);

          case 1006:
            return cc.color(255, 255, 0);

          default:
            return cc.color(255, 255, 255);
        }
    }, e.prototype.findTarget = function(e) {
        var o, t, s = this;
        void 0 === e && (e = this.node.getBoundingBox()), this.attacker && ((o = this.attacker).checkTarget(o) && o.target && o.target.node.getPosition().sub(o.node.getPosition()).mag() < this.model.RAN ? this.target = o.target : 0 < (t = r.default.getInstance().gameView.targets.filter(function(e) {
            return e.model.group != o.model.group && e.checkTarget(e) && e.canHurt();
        }).sort(function(e, t) {
            return e.node.getPosition().sub(o.node.getPosition()).mag() - t.node.getPosition().sub(o.node.getPosition()).mag();
        })).length && t[0].node.getPosition().sub(o.node.getPosition()).mag() < this.model.RAN ? this.target = t[0] : 0 < (e = r.default.getInstance().gameView.astar.retrieve(e).filter(function(e) {
            return e.isCanAttacked(s.model.type);
        }).sort(function(e, t) {
            return e.node.getPosition().sub(o.node.getPosition()).mag() - t.node.getPosition().sub(o.node.getPosition()).mag();
        })).length && e[0].node.getPosition().sub(this.node.getPosition()).mag() < 320 && (this.target = e[0]));
    }, e.prototype.updateDir = function(e) {
        0 == e.x ? 0 < e.y ? this.node.angle = 90 : e.y < 0 ? this.node.angle = -90 : this.node.angle = 0 : this.node.angle = cc.misc.radiansToDegrees(Math.atan2(e.y, e.x)), 
        this.sprite && (this.sprite.node.angle = this.node.angle + 90);
    }, e.prototype.update = function(e) {
        if (r.default.getInstance().gameView && this.model && !this.isDestory) {
            switch (this.model.type) {
              case s.ArmType.暴力枪:
              case s.ArmType.闪电枪:
                break;

              case s.ArmType.反弹枪:
                this.doBounce(e);
                break;

              case s.ArmType.导弹枪:
                this.speed.mulSelf(1.05), this.doMissile(e) ? this.doDestory() : this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              case s.ArmType.激光枪:
                break;

              case s.ArmType.冰冻枪:
                this.doMissile(e) ? this.doDestory() : this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              case s.ArmType.火焰枪:
                this.speed.equals(cc.Vec2.ZERO) || this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              case s.ArmType.火球:
                this.doMissile(e) ? this.doDestory() : this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              case s.ArmType.落雷:
                break;

              case s.ArmType.回旋:
                this.speed && this.speed.rotateSelf(cc.misc.degreesToRadians(3)), this.speed.equals(cc.Vec2.ZERO) || this.check(e) || this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              case s.ArmType.毒液:
              case s.ArmType.冲击:
                break;

              case s.ArmType.追踪:
                this.isFollow && (this.check(e) ? this.doDestory() : (this.target && this.target.node && this.target.node.active || this.findTarget(cc.rect(this.node.x - 200, this.node.y - 200, 400, 400)), 
                this.target && this.target.node && (this.targetDir = this.target.node.getPosition().sub(this.node.getPosition()).normalize()), 
                this.targetDir && (this.speed = this.speed.normalize().add(this.targetDir.mul(.2)).normalize().mul(this.model.MOV)), 
                this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)))));
                break;

              case s.ArmType.旋风:
                this.speed && this.speed.rotateSelf(cc.misc.degreesToRadians(3)), this.speed.equals(cc.Vec2.ZERO) || this.check(e) || this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              case s.ArmType.闪雷:
                this.doMissile(e) ? this.doDestory() : this.node.setPosition(this.node.getPosition().add(this.speed.mul(e)));
                break;

              default:
                this.speed.equals(cc.Vec2.ZERO) || (this.check(e) ? this.doDestory() : this.node.setPosition(this.node.getPosition().add(this.speed.mul(e))));
            }
            this.skeleton && this.skeleton.node.setPosition(this.node.getPosition()), this.sprite && this.sprite.node.setPosition(this.node.getPosition()), 
            this.duration && (this.time < this.duration && (this.time += e), this.time >= this.duration && this.doDestory());
        }
    }, e.prototype.hintBlock = function(e) {
        var t = e.isCanBlock(this.model.type);
        return e.isCanAttacked(this.model.type) && e.doHurt(this.model, this.dir), t;
    }, e.prototype.hintTarget = function(e) {
        e = e.getComponent(l.default);
        return !(!e || !e.checkTarget(e) || (e.doHurt(this.model, this.dir), 0));
    }, e.prototype.getRectByVec = function(e, t, o) {
        if (0 < o) {
            var s = e.add(t.rotate(cc.misc.degreesToRadians(o))), i = e.add(t.rotate(cc.misc.degreesToRadians(-o))), n = e.add(t), a = Math.min(e.x, s.x, i.x, n.x), r = Math.min(e.y, s.y, i.y, n.y);
            return a == (l = Math.max(e.x, s.x, i.x, n.x)) && (l += 1), r == (i = Math.max(e.y, s.y, i.y, n.y)) && (i += 1), 
            cc.rect(a, r, l - a, i - r);
        }
        var l, n = e.add(t), a = Math.min(e.x, n.x), r = Math.min(e.y, n.y);
        return a == (l = Math.max(e.x, n.x)) && (l += 1), r == (i = Math.max(e.y, n.y)) && (i += 1), 
        cc.rect(a, r, l - a, i - r);
    }, a([ p ], e);
}(cc.Component);

n.default = h;